get Invalid Lot Match Sell Txns
Validates the integrity of cost-basis lot matching for a lot-controlled Security Account. Checks performed:
Applies only to lot-controlled securities (average cost always valid).
Scans all investment txns for the security account to build buy/sell tables. • Buy/Sell transactions for zero shares are ignored (and not considered invalid).
For each sell, confirms: • The sell's "cost_basis" (buy matching) parameter is valid. • computes the parsed matched-share quantity via getNumShares() - this only includes quantities where the matched buy txn actually exists. • the calculated matched qty equals the actual sell quantity (if it doesn't then txns were changed after the matching was performed).
Then builds a table of validated matched buys for the sell being validated. >> Records each validated matched-buy quantity, in the sell's date terms together with the sell date, against its buy in an 'all valid matched buys' table. This represents every sell attempting to match each buy.
For every matched buy in the table, verify: • The buy transaction exists. • The lot is walked forward through its matched sells in date order: before each sell, the remaining lot quantity is adjusted for splits from the previous transaction date to the sell date, then the sell quantity is deducted. A sell dated before its buy (bad data) is brought forward to the buy date instead. • The buy is over-allocated as soon as the remaining quantity becomes negative.
Since
MD2027
Return
a list of sell transactions that are not fully/properly matched to buys, causing an invalid cost basis on the security account. If the result is null or empty, then the cost basis will be valid. When using failFast then returned results will only contain the first sell transaction found to be improperly matched to buys.
Parameters
The security account to validate.
Default: null. Specify the set of transactions to operate on.
Defult: false. When true short-circuits the validation checks and returns after first detected error/txn.
Enable debug messages for this validation.